<template>
  <div class="mul-input-item-wrap">
    <el-input v-model="selectData" :maxlength="maxLength" :placeholder="placeholder" @input="change" />
    <div v-if="isCanDelete && showDel" class="delete-btn" @click="deleteFun">删除</div>
  </div>
</template>
<script>
import { codelimit } from '@/utils/numFormat';
export default {
  name: 'MulInputItemWrap',
  model: {
    prop: 'params',
    event: 'change'
  },
  props: {
    params: {
      type: Number | String,
      default: () => {
        return null;
      }
    },
    index: {
      type: Number,
      default: null
    },
    placeholder: {
      type: String,
      default: ''
    },
    isCanDelete: {
      type: Boolean,
      default: true
    },
    maxLength: {
      type: Number,
      default: 20
    },
    showDel: {
      type: Boolean,
      default: true
    }
  },
  computed: {
    selectData: {
      get() {
        return this.params;
      },
      set(val) {
        this.$emit('change', val);
      }
    }
  },
  methods: {
    deleteFun() {
      this.$emit('delete', this.index);
    },
    change(value) {
      const str = codelimit(value);
      this.selectData = str;
    }
  }
};
</script>
<style lang="scss" scoped>
.mul-input-item-wrap {
  display: flex;
  .delete-btn {
    margin-left: 16px;
    cursor: pointer;
    font-weight: bold;
    color: #192452;
    font-size: 14px;
  }
}
</style>
